﻿using System.Windows.Controls;
using Microsoft.Devices.Sensors; 


namespace Coding4Fun.Cannon.TechEdPhone.Complete.Controls
{
	public partial class AimView : AccelerometerUserControl
	{
		private const string AngleFormat = "00.0";
		private const string RawFormat = "0.00";

		public AimView() 
		{
			InitializeComponent();             
		}

		public override void AccelerometerReadingChanged(SensorData<AccelerometerReading> data)
		{
			
            txtAccelerometer.Text = string.Format("X:{0}, Y:{1}, Z:{2}",
				data.Value.X.ToString(RawFormat),
				data.Value.Y.ToString(RawFormat),
				data.Value.Z.ToString(RawFormat));

            uxHorizontalSlider.Value = double.Parse(CannonAim.CurrentPan.ToString(AngleFormat));

            App.Service.Aim(CannonAim.CalculatePan(data.Value.Y), 20); 
		}


	}
}
